#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main()
{
	int n;
	cin >> n;
	for (int i = 0;i < n;i++) {
		string str;
		cin >> str;
		if (str[0] >= 'a' && str[0] <= 'z')
			printf("%c", str[0] - 32);
		else
			cout << str[0];
		for (int j = 1;j < str.length();j++) {
			if (str[j] >= 'A' && str[j] <= 'Z')
				printf("%c", str[j] + 32);
			else
				cout << str[j];
		}
		cout << endl;
	}
	return 0;
}